package com.ztools.wx.controller;

import com.ztools.common.util.common.Result;
import com.ztools.wx.service.WxPayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: seeTools
 * @Date: 2023/6/3  21:20
 * @Version 1.0
 * 支付controller层
 */
@RestController
@RequestMapping("/wx/pay")
public class WxPayController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Resource
    private WxPayService wxPayService;

    @RequestMapping("/submit")
    public Result submitOrder(@RequestBody Map<String, String> map) {
        logger.info("下单参数：{}", map);
        String method = map.get("method");
        Result result = Result.error();
        switch (method) {
            // 线上商城下单
            case "store":
                result = wxPayService.storePay(map);
                break;
            default:
                logger.warn("下单参数有问题");
                break;
        }
        return result;
    }

}
